package weeek11.topic04;

import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

/**
 * @author lfy
 */
public class LruCache<K, V> extends LinkedHashMap<K,V> {
    static  float loadFactor  = 0.75f;
    int cacheSize;
    public LruCache(int cacheSize) {
        super ((int) Math.ceil(cacheSize / loadFactor) + 1, loadFactor,true);
        this.cacheSize = cacheSize;
    }
    @Override
    protected boolean removeEldestEntry(Map.Entry<K, V> eldest) {
        return size() > this.cacheSize;
    }
}
